﻿-- 
-- Alter script for ParaDM v3.1.x - v.3.2.0
--

-- By Lun Au (2005-02-24)
ALTER TABLE WORKFLOW_SCHEDULE_TRIGGERS ADD START_TIME INT
GO

-- By Lun Au (2005-03-23)
-- Workflow Permission Implementation
ALTER TABLE MTM_WF_STEP_USER_ACTOR ADD PERMISSION NVARCHAR(100)
GO
UPDATE MTM_WF_STEP_USER_ACTOR SET PERMISSION='RMW';

-- By Lun Au (2005-03-23)
-- Requested by Jenny
INSERT INTO SYS_PARAMETER VALUES (6065,'dms.archive_excel_size','2M','I','Archive excel size','A',0,0,getdate(),0,getdate());

-- By Lun Au (2005-03-29)
-- Fix bug 1564
UPDATE SYS_FUNCTION SET DISPLAY_SEQ=5 WHERE ID = 4000;
UPDATE SYS_FUNCTION SET DISPLAY_SEQ=6 WHERE ID = 3000;    
-- Loopback all branches
ALTER TABLE MTM_WF_STEP_WF_STEP ADD LOOP_BACK_ALL_BRANCH CHAR(1)
GO

-- By Lun Au (2005-04-20)
-- Requested by Zealot
ALTER TABLE MTM_FORM_SECTION_FORM_ELEMENT ADD END_ROW CHAR(1)
GO
UPDATE MTM_FORM_SECTION_FORM_ELEMENT SET END_ROW='Y';
ALTER TABLE MTM_FORM_SECTION_FORM_ELEMENT ADD ROW_INDEX INT
GO
ALTER TABLE FORM_DATA_ELEMENT ADD ELEMENT_SEQ INT
GO
UPDATE FORM_DATA_ELEMENT SET ELEMENT_SEQ=1;

-- By Lun Au (2005-04-21)
-- Requestd by Zealot
UPDATE MTM_FORM_SECTION_FORM_ELEMENT SET ROW_INDEX= 0 WHERE ROW_INDEX IS NULL;

-- By Lun Au (2005-04-25)
-- Requested by Zealot
CREATE TABLE FORM_DATA_ROW (
  ID int NOT NULL,
  PAGE_ID int NOT NULL,
  SECTION_ID int,
  SUBMISSION_ID int NOT NULL,
  ROW_INDEX int,
  WORKFLOW_PROGRESS_ID int,
  SEQ int,
  ROW_COUNT int DEFAULT 1,
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO

-- By Lun Au (2005-04-29)
-- Protected Resources
CREATE TABLE PROTECTED_RESOURCE (
  ID  int NOT NULL,
  URL_PATTERN varchar(255) NOT NULL,
  NAV_MODE varchar(10), 
  OP_MODE varchar(10), 
  HELPER_CLASS varchar(100) NOT NULL,
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO

CREATE TABLE PROTECTED_OBJECT (
  ID int NOT NULL,
  RESOURCE_ID int NOT NULL,
  OBJECT_VALUE varchar(255),
  PROTECTION varchar(100),
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO

-- By Lun Au (2005-04-29)
-- Requested by Jerry
INSERT INTO SYS_PARAMETER VALUES (6066,'dms.myFavorite_enable ','true','B','Select true to enable My Favorite feature.','A',0,0,getdate(),0,getdate());
INSERT INTO SYS_PARAMETER VALUES (6067,'dms.myFavorite_folder_name ','My Favorite','S','My Favorite default folder name.','A',0,0,getdate(),0,getdate());

-- By Lun Au (2005-05-09)
-- Holiday setup
CREATE TABLE HOLIDAY_RECORD  (
  ID int NOT NULL,
  WORKING_CALENDAR_ID int NOT NULL,
  HOLIDAY_NAME nvarchar(50) NOT NULL,
  HOLIDAY_TYPE int NOT NULL,
  START_DATE datetime NOT NULL,
  END_DATE datetime NOT NULL,
  DESCRIPTION nvarchar(255) NULL,
  REFERENCE_FLAG char(1) NOT NULL,
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO
 
CREATE TABLE WORKING_CALENDAR  (
  ID int NOT NULL,  
  WORKING_CALENDAR_NAME nvarchar(50)  NOT NULL,
  DESCRIPTION   nvarchar(255)   NULL,  
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO
 
CREATE TABLE MTM_WORKING_CALENDAR_OBJECT  (
  ID int NOT NULL,  
  WORKING_CALENDAR_ID int NOT NULL,
  OBJECT_ID int NOT NULL,
  OBJECT_TYPE  char(1)   NOT NULL,  
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO

INSERT INTO SYS_FUNCTION VALUES (1008,'STP_HOLIDAY_RECORD','Holiday Setup',N'假期設定',N'假期设定','1000','/setup/ListHolidayRecord.do',8,'S','RIECD','A',0,getdate(),0,getdate());

-- Multi-form and form enhancement
ALTER TABLE FORM_SUBMISSION ADD TRACK_ID INT
GO
ALTER TABLE FORM_SUBMISSION ADD WORKFLOW_RECORD_ID INT
GO

UPDATE SYS_FUNCTION SET ID= 7007, DISPLAY_SEQ= 7 WHERE ID=7006;
UPDATE SYS_FUNCTION SET ID= 7006, DISPLAY_SEQ= 6 WHERE ID=7005;
UPDATE SYS_FUNCTION SET ID= 7005, DISPLAY_SEQ= 5 WHERE ID=7004;
UPDATE SYS_FUNCTION SET ID= 7004, DISPLAY_SEQ= 4 WHERE ID=7003;
INSERT INTO SYS_FUNCTION VALUES (7003,'FMB_TASK','Form Task',N'待遞表單',N'待递表单',7000,'/form/ListFormTask.do',3,'S','R','A',0,getdate(),0,getdate());

CREATE TABLE MTM_WF_STEP_FORM_RECORD (
  ID int NOT NULL,
  WORKFLOW_STEP_ID int NOT NULL,
  FORM_RECORD_ID int NOT NULL,
  FORM_PAGE_ID int ,
  FORM_SECTION_ID int ,
  FORM_ELEMENT_ID int ,
  PERMISSION char(1) NOT NULL,
  MANDATORY char(1) NOT NULL,
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO

CREATE TABLE MTM_WF_PROGRESS_ACCESS_FORM (
  ID int NOT NULL,
  WORKFLOW_PROGRESS_ID int NOT NULL,
  FORM_RECORD_ID int NOT NULL,
  FORM_SUBMISSION_ID int ,
  PROCESSED char(1) NOT NULL,
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NULL,
  PRIMARY KEY  (ID)
)
GO
--------------------------------------------------------------------------
--- PLEASE EXECUTE /jsp/admin/alter3.1.7_3.1.8.jsp for data conversion ---
--------------------------------------------------------------------------

-- By Lun Au (2005-05-10)
-- Requested By Vera
CREATE TABLE FORM_FILE_ATTACHMENT (
  ID int NOT NULL,
  FORM_DATA_ELEMENT_ID int NOT NULL,
  ATTACHMENT_NAME nvarchar(255),
  ATTACHMENT_TYPE char(1) NOT NULL,
  EXTERNAL_ID nvarchar(30) NOT NULL,
  CONTENT_SIZE int NOT NULL,
  FLOW_TYPE char(1) NOT NULL,
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO

-- By Lun Au (2005-05-10)
-- Enhancement 1602
INSERT INTO SYS_PARAMETER VALUES (9025,'workflow.allow_to_proceed_next_task_immediately', 'false', 'B', 'Allow user to proceed next task immediately after complete a task', 'A', 0, 0, getdate(),0,getdate());

-- By Lun Au (2005-05-14)
-- Workflow due date setup
ALTER TABLE WORKFLOW_STEP ADD ON_NO_RESPONSE_CALENDAR_ID INT
GO
INSERT INTO WORKING_CALENDAR VALUES (0,'Default Working Calendar','Default Working Calendar','A',0,0,getdate(),0,getdate());
INSERT INTO SYS_TABLE_KEY VALUES ( 'WORKING_CALENDAR', 0);

-- By Lun Au (2005-05-24)
-- Requested by Vera
CREATE TABLE FORM_ROUTING_RULE (
  ID int NOT NULL,
  FORM_RECORD_ID int NOT NULL,
  RULE_NAME nvarchar(255) NOT NULL,
  RULE_TYPE char(1) NOT NULL,
  OPERATION_TYPE char(1) NOT NULL,
  FORM_EQUATION image NOT NULL,
  FORM_OPERATION_EQUATION image NOT NULL,
  TARGET_ELEMENT_ID varchar(100), 
  CHECK_RULE varchar(10),
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO

-- By Lun Au (2005-05-27)
-- Multiform disable form task menu
UPDATE SYS_FUNCTION SET STATUS= 'I' WHERE ID=7003;

-- By Lun Au (2005-05-28)
-- Default working calendar
UPDATE WORKING_CALENDAR SET ID=1;
UPDATE SYS_TABLE_KEY SET TABLE_KEY_MAX=1 WHERE TABLE_NAME='WORKING_CALENDAR';

-- By Lun Au (2005-06-13)
-- Requested by Zealot
ALTER TABLE MTM_FORM_SECTION_FORM_ELEMENT ADD MULTIPLE CHAR(1)
GO
UPDATE MTM_FORM_SECTION_FORM_ELEMENT SET MULTIPLE = 'N';

-- By Lun Au (2005-06-14)
-- Temporarily only have RW permission
UPDATE MTM_WF_STEP_USER_ACTOR SET PERMISSION='RW';

-- By Lun Au (2005-06-17)
-- Interruption request approval
INSERT INTO WORKFLOW_ACTION VALUES (24,'workflow.action.label.subworkflow_approve_interrupt_request', 15, 'com.dcivision.workflow.action.ApproveInterruptRequest', 'A', 0, 0,getdate(),0,getdate());

-- By Lun Au (2005-06-21)
-- Workflow's automatic parameters
CREATE TABLE WORKFLOW_STEP_PARAMETER_VALUE (
  ID int NOT NULL,
  WORKFLOW_STEP_ID int NOT NULL,
  PARAMETER_NAME nvarchar(255) NOT NULL,
  PARAMETER_VALUE nvarchar(255),
  PARAMETER_TYPE char(1) NOT NULL,
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO

-- Trigger sub workflow
INSERT INTO WORKFLOW_ACTION VALUES (25,'workflow.action.label.trigger_subworkflow_auto_task', NULL, 'com.dcivision.workflow.action.TriggerSubWorkflow', 'A', 0, 0,getdate(),0,getdate());

-- Requested by Jenny
INSERT INTO SYS_PARAMETER VALUES (6069,'dms.enable_archive_excel_file','true','B','Determine whether to have excel report file in archive','A',0,0,getdate(),0,getdate());

-- By Lun Au (2005-06-30)
-- Workflow stages and report
CREATE TABLE WORKFLOW_STAGE (
  ID INT NOT NULL,
  WORKFLOW_RECORD_ID INT NOT NULL,
  STAGE_NAME NVARCHAR(60) NOT NULL,
  DURATION INT,
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID),
  UNIQUE (WORKFLOW_RECORD_ID, STAGE_NAME)
)
GO

CREATE TABLE MTM_WF_STAGE_WF_STEP (
  ID INT NOT NULL,
  WORKFLOW_STAGE_ID INT NOT NULL,
  WORKFLOW_STEP_ID INT NOT NULL,
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY (ID)
)
GO

UPDATE SYS_FUNCTION SET DISPLAY_SEQ=7 WHERE ID=8004;
UPDATE SYS_FUNCTION SET DISPLAY_SEQ=8 WHERE ID=8005;
INSERT INTO SYS_FUNCTION VALUES (8008,'WFM_REPORT','Report',N'流程報表',N'流程报表',8000,'/workflow/ListWorkflowAnalysisReport.do',6,'S','R','A',0,getdate(),0,getdate());

-- By Lun Au (2005-07-06)
-- Requested by Zealot (For ParaFORM)
ALTER TABLE MTM_FORM_PAGE_FORM_SECTION ADD MULTIPLE CHAR(1)
GO
ALTER TABLE FORM_DATA_ELEMENT ADD SECTION_SEQ INT
GO
ALTER TABLE FORM_DATA_ROW ADD SECTION_SEQ INT
GO
UPDATE FORM_DATA_ELEMENT SET SECTION_SEQ = 1;
UPDATE FORM_DATA_ROW SET SECTION_SEQ = 1;

-- By Lun Au (2005-07-20)
-- Requested by Anson, System parameter default value
ALTER TABLE SYS_PARAMETER ADD PARAMETER_DEFAULT_VALUE nvarchar(200)
GO
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='$RCSfile: alter3.1.7_3.1.8.sql,v $,$Revision: 1.66 $' WHERE ID=-1;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='UTF-8' WHERE ID=1001;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='en_US' WHERE ID=1002;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='3' WHERE ID=1003;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='true' WHERE ID=1004;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='dcivision' WHERE ID=1005;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='dd-MM-yyyy' WHERE ID=1006;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='HH:mm' WHERE ID=1007;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='dd-MM-yyyy HH:mm' WHERE ID=1008;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='###,###,###,###,##0' WHERE ID=1009;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='###,###,###,###,##0.00' WHERE ID=1010;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='true' WHERE ID=1011;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='com.dcivision.user.auth.StandardAuthenticationHandler' WHERE ID=1012;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='0' WHERE ID=1013;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='yyyy-MM-dd HH:mm:ss' WHERE ID=1014;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='true' WHERE ID=1015;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=1016;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='1000' WHERE ID=1017;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='D:/ParaDM/file/Index' WHERE ID=1018;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='\\, /, :, *, ?, \", <, >, |' WHERE ID=1019;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='true' WHERE ID=1020;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='true' WHERE ID=1021;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=1022;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=1023;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=1024;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=1025;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='6' WHERE ID=1026;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=1027;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='DCIVISION ParaDM Systems' WHERE ID=2001;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='LayoutLogoDefault.gif' WHERE ID=2002;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='LayoutLoginLogoDefault.gif' WHERE ID=2003;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='10' WHERE ID=2004;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='20' WHERE ID=2005;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='true' WHERE ID=2006;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='DCIVISION Limited' WHERE ID=2007;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='DCI' WHERE ID=2008;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='10' WHERE ID=2009;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='10' WHERE ID=2010;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='10' WHERE ID=2011;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='10' WHERE ID=2012;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='10' WHERE ID=2013;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='10' WHERE ID=2014;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=2015;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='mail.dcivision.com' WHERE ID=3001;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE=NULL WHERE ID=3002;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE=NULL WHERE ID=3003;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE=NULL WHERE ID=3004;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=3005;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='ParaDM System Administrator' WHERE ID=3006;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='system@dcivision.com' WHERE ID=3007;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='0' WHERE ID=3008;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='Sched1' WHERE ID=4001;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='1' WHERE ID=4002;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=4003;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=4004;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='org.quartz.simpl.SimpleThreadPool' WHERE ID=4005;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='3' WHERE ID=4006;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='4' WHERE ID=4007;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='org.quartz.impl.jdbcjobstore.JobStoreTX' WHERE ID=4008;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='org.quartz.impl.jdbcjobstore.StdJDBCDelegate' WHERE ID=4009;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='EIP_DS' WHERE ID=4010;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='SCHEDULER_' WHERE ID=4011;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='1' WHERE ID=4012;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='3' WHERE ID=4013;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='5' WHERE ID=4014;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='10' WHERE ID=5001;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='99999999' WHERE ID=6001;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='2' WHERE ID=6002;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='com.dcivision.dms.core.StandardStorageLocationResolver' WHERE ID=6003;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='com.dcivision.dms.core.StandardDocumentNameConvertor' WHERE ID=6004;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='com.dcivision.dms.core.FileSystemContentStoreHandler' WHERE ID=6005;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=6006;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=6007;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='ParaDoc Alert Notification' WHERE ID=6008;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=6009;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='true' WHERE ID=6010;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='SCAN.NAME_IN_AUTO_GEN' WHERE ID=6011;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='0' WHERE ID=6012;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='SCAN.FOLDER_CREATE_BY_UDFBY_DATE' WHERE ID=6013;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='yyyyMMddHHmmss' WHERE ID=6014;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='com.dcivision.dms.client.analyzer.DmsStandardDocumentAnalyzer' WHERE ID=6015;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='com.dcivision.framework.StandardAutoLabelGenerator' WHERE ID=6016;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='REFERENCE_NO' WHERE ID=6017;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='ParaDoc invitation notification' WHERE ID=6018;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=6019;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='0' WHERE ID=6020;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='0' WHERE ID=6021;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='com.dcivision.dms.core.StandardReferenceNoProcessor' WHERE ID=6022;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='dd/MM/yy' WHERE ID=6023;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='true' WHERE ID=6024;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='true' WHERE ID=6025;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=6026;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='true' WHERE ID=6027;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='0' WHERE ID=6028;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='15' WHERE ID=6029;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='-1' WHERE ID=6030;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='-1' WHERE ID=6031;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=6032;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=6033;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='dd-MM-yyyy' WHERE ID=6034;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='0' WHERE ID=6035;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='10' WHERE ID=6036;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='15' WHERE ID=6037;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='20' WHERE ID=6038;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='25' WHERE ID=6039;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='30' WHERE ID=6040;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='999' WHERE ID=6041;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='true' WHERE ID=6042;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='5' WHERE ID=6043;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=6044;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='true' WHERE ID=6045;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=6046;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='640M' WHERE ID=6047;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='2M' WHERE ID=6048;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='true' WHERE ID=6049;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='60000' WHERE ID=6050;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='60000' WHERE ID=6051;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=6052;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='1' WHERE ID=6053;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='15' WHERE ID=6054;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='80' WHERE ID=6055;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=6056;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='-1' WHERE ID=6057;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='-5' WHERE ID=6058;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='-4' WHERE ID=6059;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='-3' WHERE ID=6060;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='-2' WHERE ID=6061;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='-1' WHERE ID=6062;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='D:/ParaDM/file/ParaDOC/cache/' WHERE ID=6063;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='5' WHERE ID=6064;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='2M' WHERE ID=6065;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='true' WHERE ID=6066;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='My Favorite' WHERE ID=6067;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='D:/ParaDM/file/ParaDOC' WHERE ID=6068;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='true' WHERE ID=6069;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='LW' WHERE ID=7001;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='6' WHERE ID=7002;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='10' WHERE ID=7003;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='ParaDM Calendar Reminder' WHERE ID=7004;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=7005;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='2' WHERE ID=7006;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='30' WHERE ID=7007;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='D:/ParaDM/file/ParaFORM' WHERE ID=8001;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='3' WHERE ID=8002;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='com.dcivision.workflow.core.WorkflowAttachmentContentHandler' WHERE ID=9001;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='D:/ParaDM/file/ParaFLOW' WHERE ID=9002;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='5' WHERE ID=9003;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='10' WHERE ID=9004;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='PARA Flow Task Arrival Notification' WHERE ID=9005;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='PARA Flow Task Completion Notification' WHERE ID=9006;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='PARA Flow Task Overdue Notification' WHERE ID=9007;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='PARA Flow Track Stopped Notification' WHERE ID=9008;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='6' WHERE ID=9009;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='11' WHERE ID=9010;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='1' WHERE ID=9011;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='3,5,7,9' WHERE ID=9012;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='Workflow Delegation Notification' WHERE ID=9013;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='com.dcivision.workflow.core.MailScheduleManager' WHERE ID=9014;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='Workflow Delegation Notification' WHERE ID=9015;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='E,S,' WHERE ID=9016;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='3' WHERE ID=9017;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='PARA Flow Task Before Due Date Notification' WHERE ID=9018;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='PARA Flow Task Pending Notification' WHERE ID=9019;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='PARA Flow Task In Progress Notification' WHERE ID=9020;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='PARA Flow Task Priority Changed Notification' WHERE ID=9021;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='PARA Flow Task Check Out By User Notification' WHERE ID=9022;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='PARA Flow Task Completed By User Notification' WHERE ID=9023;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=9024;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='false' WHERE ID=9025;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='Document Forum Discussion' WHERE ID=10001;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='ldap://localhost:389' WHERE ID=11000;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='cn=root, dc=example, dc=com' WHERE ID=11001;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=11002;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='dc=example,dc=com' WHERE ID=11003;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='dc=example,dc=com' WHERE ID=11004;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='dn' WHERE ID=11100;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=11101;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=11102;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=11103;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=11104;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=11105;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=11106;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='dn' WHERE ID=11107;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=11108;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=11109;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=11110;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=11111;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=12001;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=12002;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=12003;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=12004;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=12005;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=12006;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=13001;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=13002;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='/businessobjects/viewrpt.cwr' WHERE ID=13003;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='Administrator' WHERE ID=13004;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='' WHERE ID=13005;
UPDATE SYS_PARAMETER SET PARAMETER_DEFAULT_VALUE='U2FPDF:0' WHERE ID=13006;

-- By Lun Au (2005-07-20)
-- Requested by Roy
ALTER TABLE DMS_DOCUMENT MODIFY DESCRIPTION TEXT default NULL
GO
ALTER TABLE DMS_VERSION MODIFY DESCRIPTION TEXT default NULL
GO

-- By Lun Au (2005-07-25)
-- Requested by Charlie
INSERT INTO SYS_PARAMETER (ID, PARAMETER_CODE, PARAMETER_VALUE, PARAMETER_DEFAULT_VALUE, PARAMETER_TYPE, DESCRIPTION, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE)
VALUES (1028, 'system.session_timeout', '300', '300', 'I', 'user session timeout', 'A', 0, 0, getdate(),0,getdate());

-- By Lun Au (2005-08-11)
-- Dynamic assign owner permission
ALTER TABLE MTM_WF_DYNAMIC_USER_ACTOR ADD PERMISSION VARCHAR(20) AFTER ACTOR_ID
GO
UPDATE MTM_WF_DYNAMIC_USER_ACTOR SET PERMISSION='RW';

-- By Lun Au (2005-08-29)
-- Requested by Vera
ALTER TABLE FORM_ELEMENT ADD FREEZED CHAR(1)
GO

-- By Lun Au (2005-09-05)
-- Requested by Samlin for bug 3278
ALTER TABLE WORKFLOW_STAGE MODIFY STAGE_NAME NVARCHAR(60)
GO

-- By Lun Au (2005-09-12)
-- Requested by Anson (Event Logger)
CREATE TABLE EVENT_MESSAGE_CODE (
  ID int NOT NULL,
  EVENT_TYPE char(1) NOT NULL,
  MESSAGE_PATTERN nvarchar(255),
  MESSAGE_CODE nvarchar(255),
  ERROR_LABEL_KEY nvarchar(255),
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO

CREATE TABLE MTM_EVENT_MESSAGE_LOG (
  ID int NOT NULL,
  MESSAGE_CODE_ID int NOT NULL,
  MESSAGE nvarchar(255),
  SOURCE_FUNCTION_CODE nvarchar(30),
  ERROR_DETAIL nvarchar(4000),
  ACTION_TAKER_ID int NOT NULL,
  SERVER_NAME nvarchar(255),
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO

INSERT INTO SYS_FUNCTION VALUES (2003,'LOG_EVENT_MESSAGE','Event Log',N'事件日誌',N'事件日誌',2000,'/log/ListEventMessge.do',2,'S','RIED','A',0,'2005-09-06 15:30:00',0,'2005-09-06 15:30:00');

INSERT INTO SYS_PARAMETER (ID, PARAMETER_CODE, PARAMETER_VALUE, PARAMETER_DEFAULT_VALUE, PARAMETER_TYPE, DESCRIPTION, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE) 
VALUES (1029, 'systemlog.eventlog', '1', '1','I','Event viewer logging level','A',0,0,getdate(),0,getdate());

INSERT INTO SYS_PARAMETER (ID, PARAMETER_CODE, PARAMETER_VALUE, PARAMETER_DEFAULT_VALUE, PARAMETER_TYPE, DESCRIPTION, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE) 
VALUES (1030, 'systemlog.eventlog.errorDetail', '0', '0','I','Maximum length to capture exception messages','A',0,0,getdate(),0,getdate());

-- By Lun Au (2005-09-20)
-- Requested by Beyond
ALTER TABLE DMS_DOCUMENT ADD EXT_REF NVARCHAR(255)
GO

-- By Lun Au (2005-09-21)
-- Requested by Vera
ALTER TABLE FORM_DATA_ELEMENT ADD SUBMIT_FLAG NVARCHAR(3)
GO

-- By Lun Au (2005-10-14)
-- Requested by Beyond Qu
INSERT INTO SYS_PARAMETER (ID, PARAMETER_CODE, PARAMETER_VALUE, PARAMETER_DEFAULT_VALUE, PARAMETER_TYPE, DESCRIPTION, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE)
VALUES (6075, 'dms.enable_emailArchive_auto_tracker', 'false', 'false','B','Enable auto email archive','A',0,0,getdate(),0,getdate());
INSERT INTO SYS_PARAMETER (ID, PARAMETER_CODE, PARAMETER_VALUE, PARAMETER_DEFAULT_VALUE, PARAMETER_TYPE, DESCRIPTION, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE)
VALUES (6076, 'dms.emailArchive_auto_tracker_time_interval', '5', '5','I','Email archive auto receive interval in minute','A',0,0,getdate(),0,getdate());
INSERT INTO SYS_PARAMETER (ID, PARAMETER_CODE, PARAMETER_VALUE, PARAMETER_DEFAULT_VALUE, PARAMETER_TYPE, DESCRIPTION, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE)VALUES (6077, 'dms.emailArchive_auto_tracker_incoming_server_host', '', '','S','Host address to receive incoming email using auto email archive function','A',0,0,getdate(),0,getdate());
VALUES (6078, 'dms.emailArchive_auto_tracker_incoming_server_loginname', '', '','S','Login name to receive incoming email using auto email archive function','A',0,0,getdate(),0,getdate());
INSERT INTO SYS_PARAMETER (ID, PARAMETER_CODE, PARAMETER_VALUE, PARAMETER_DEFAULT_VALUE, PARAMETER_TYPE, DESCRIPTION, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE)VALUES (6079, 'dms.emailArchive_auto_tracker_incoming_server_password', '', '','S','Password to receive incoming email using auto email archive function','A',0,0,getdate(),0,getdate());
VALUES (6080, 'dms.emailArchive_auto_tracker_outgoing_server_host', '', '','S','Host address to receive outgoing email using auto email archive function','A',0,0,getdate(),0,getdate());
INSERT INTO SYS_PARAMETER (ID, PARAMETER_CODE, PARAMETER_VALUE, PARAMETER_DEFAULT_VALUE, PARAMETER_TYPE, DESCRIPTION, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE)VALUES (6079, 'dms.emailArchive_auto_tracker_incoming_server_password', '', '','S','Password to receive incoming email using auto email archive function','A',0,0,getdate(),0,getdate());
VALUES (6081, 'dms.emailArchive_auto_tracker_outgoing_server_loginname', '', '','S','Login name to receive outgoing email using auto email archive function','A',0,0,getdate(),0,getdate());
INSERT INTO SYS_PARAMETER (ID, PARAMETER_CODE, PARAMETER_VALUE, PARAMETER_DEFAULT_VALUE, PARAMETER_TYPE, DESCRIPTION, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE)VALUES (6079, 'dms.emailArchive_auto_tracker_incoming_server_password', '', '','S','Password to receive incoming email using auto email archive function','A',0,0,getdate(),0,getdate());
VALUES (6082, 'dms.emailArchive_auto_tracker_outgoing_server_password', '', '','S','Password to receive outgoing email using auto email archive function','A',0,0,getdate(),0,getdate());
INSERT INTO SYS_PARAMETER (ID, PARAMETER_CODE, PARAMETER_VALUE, PARAMETER_DEFAULT_VALUE, PARAMETER_TYPE, DESCRIPTION, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE)VALUES (6079, 'dms.emailArchive_auto_tracker_incoming_server_password', '', '','S','Password to receive incoming email using auto email archive function','A',0,0,getdate(),0,getdate());
VALUES (6083, 'dms.emailArchive_auto_tracker_mail_servertype', 'pop3', 'pop3','S','Auto email archive server protocol ','A',0,0,getdate(),0,getdate());

-- Requested by Tony Chen
INSERT INTO SYS_PARAMETER (ID, PARAMETER_CODE, PARAMETER_VALUE, PARAMETER_DEFAULT_VALUE, PARAMETER_TYPE, DESCRIPTION, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE)VALUES (6079, 'dms.emailArchive_auto_tracker_incoming_server_password', '', '','S','Password to receive incoming email using auto email archive function','A',0,0,getdate(),0,getdate());
VALUES(14001, 'rules.kb_driver_class', 'org.mandarax.zkb.framework.ZKBDriver_2_0', 'org.mandarax.zkb.framework.ZKBDriver_2_0', 'S', 'ZKB driver', 'A', '0', '0', getdate(),0,getdate());
INSERT INTO SYS_PARAMETER (ID, PARAMETER_CODE, PARAMETER_VALUE, PARAMETER_DEFAULT_VALUE, PARAMETER_TYPE, DESCRIPTION, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE)VALUES (6079, 'dms.emailArchive_auto_tracker_incoming_server_password', '', '','S','Password to receive incoming email using auto email archive function','A',0,0,getdate(),0,getdate());
VALUES(14002, 'rules.kb_file_path', 'D:/ParaDM/file/KB', 'D:/ParaDM/file/KB', 'S', 'Knowledge base rule file storage location', 'A', '0', '0', getdate(),0,getdate());
INSERT INTO SYS_FUNCTION VALUES(6013, 'DMS_PUBLIC_RULE_SETUP', 'Public Email Rule', N'公共電郵規則', N'公共电邮规则', '6000', '/dms/ListEmailArchiveRule.do', '14', 'S', 'RIED', 'A', '0', getdate(),0,getdate());
INSERT INTO SYS_FUNCTION VALUES(6014, 'DMS_PRIVATE_RULE_SETUP', 'Private Email Rule', N'私人電郵規則', N'私人电邮规则', '6000', '/dms/ListEmailArchiveRule.do?ruleType=R', '15', 'H', 'RIED', 'A', '0', getdate(),0,getdate());

-- By Lun Au (2005-10-19)
-- Requested by Charlie
CREATE TABLE MTM_FORM_DYNAMIC_VALUE (
  ID int NOT NULL,
  CONDITION_ELEMENT_ID int NOT NULL,
  DYNAMIC_ELEMENT_ID int NOT NULL,
  SQL_STATEMENT nvarchar(255) NOT NULL,
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO

-- By Lun Au (2005-10-27)
-- Requested by Tony
ALTER TABLE WORKFLOW_QUERY_RECORD ADD WORKFLOW_GROUP_ID INT
GO

-- By Lun Au (2005-11-18)
-- Requested by Ferdinand
CREATE TABLE FORM_VALIDATION_RULE (
  ID int NOT NULL,
  VALIDATION_RULE char(1) NOT NULL,
  REGULAR_EXPR nvarchar(255) NOT NULL,
  LABEL_MSG_KEY nvarchar(255) NOT NULL,
  DESCRIPTION_MSG_KEY nvarchar(255) NULL,
  ERROR_MSG_KEY nvarchar(255) NOT NULL,
  RECORD_STATUS CHAR(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO

ALTER TABLE FORM_ELEMENT ADD UNIQUENESS CHAR(1)
GO

INSERT INTO FORM_VALIDATION_RULE VALUES('1', 'S', '/^[a-zA-Z\\s]*$/', 'form.label.validation_alphabet_only', 'Alphabet Only', 'errors.form.label.validate_alphabet', 'A',0,0,getdate(),0,getdate());
INSERT INTO FORM_VALIDATION_RULE VALUES('2', 'S', '/^[\\u4E00-\\u9FA5]*$/', 'form.label.validation_chinese', 'Chinese', 'errors.form.label.validate_chinese', 'A',0,0,getdate(),0,getdate());
INSERT INTO FORM_VALIDATION_RULE VALUES('3', 'I', '/^[-+]?\\d*$/', 'form.label.validation_integer_only', 'Integer Only', 'errors.form.label.validate_integer', 'A',0,0,getdate(),0,getdate());
INSERT INTO FORM_VALIDATION_RULE VALUES('4', 'F', '/^[-+]?\\d*(\\.\\d*)?$/', 'form.label.validation_numeric_only', 'Number Only', 'errors.form.label.validate_number', 'A',0,0,getdate(),0,getdate());
INSERT INTO FORM_VALIDATION_RULE VALUES('5', 'S', '/^(\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*)?$/', 'form.label.validation_email_format', 'Email Format', 'errors.form.label.validate_email', 'A',0,0,getdate(),0,getdate());

-- By Lun Au (2005-11-21)
-- Requested by Ferdinand
CREATE TABLE FORM_REFERENCE_FIELD (
  ID int NOT NULL,
  ELEMENT_ID int NOT NULL,
  START_VALUE int NOT NULL,
  INCREMENT_VALUE int NOT NULL,
  CURRENT_VALUE int NOT NULL,
  LENGTH int NOT NULL,
  CYCLE char(1) NOT NULL,
  LAST_CYCLE_VALUE datetime,
  TOTAL int NOT NULL,
  FORMAT nvarchar(255) NOT NULL,
  DESCRIPTION nvarchar(255),
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO

-- By Lun Au (2005-11-28)
-- Requested by Anson, bug 4106
CREATE TABLE DMS_RETENTION_SETUP (
  ID int NOT NULL,
  OBJECT_TYPE char(1) NOT NULL,
  OBJECT_ID int NOT NULL,
  PERIOD_YEAR int,
  PERIOD_MONTH int,
  PERIOD_DAY int,
  OFFSET nvarchar(200),
  PRIORITY char(1) NOT NULL,
  ACTION_NAME nvarchar(20),
  DESCRIPTION nvarchar(255),
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO

-- By Lun Au (2006-04-21)
-- Requested by Lee
UPDATE SYS_FUNCTION SET PERMISSION_TYPE= 'RIECDP' WHERE ID=4002;

-- By Lun Au (2006-07-06)
-- Requested by Simon
ALTER TABLE MTM_WF_PROGRESS_USER_RECORD ADD OPERATION_PARAMETER NVARCHAR(10)
GO

-- By Lun Au (2006-09-06)
-- Requested by Great Wall, For automatic task hot deploy enhancement
INSERT INTO SYS_FUNCTION VALUES (8010,'WFM_AUTOMATICTASK','Automatic Task',N'自動步驟',N'自动步骤',8000,'/workflow/ListWorkflowAutomaticTask.do',9,'S','RIECD','A',0,getdate(),0,getdate()); 
INSERT INTO SYS_PARAMETER (ID, PARAMETER_CODE, PARAMETER_VALUE, PARAMETER_DEFAULT_VALUE, PARAMETER_TYPE, DESCRIPTION, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE)VALUES (6079, 'dms.emailArchive_auto_tracker_incoming_server_password', '', '','S','Password to receive incoming email using auto email archive function','A',0,0,getdate(),0,getdate());
VALUES(9033,'workflow.automatic_task_srcdir','D:/ParaDM/file/ParaFlow/AUTOMATICTASK/SRC','D:/ParaDM/file/ParaFlow/AUTOMATICTASK/SRC','S','Automatic Task Java Source Directory','A',0,0,getdate(),0,getdate()); 
INSERT INTO SYS_PARAMETER (ID, PARAMETER_CODE, PARAMETER_VALUE, PARAMETER_DEFAULT_VALUE, PARAMETER_TYPE, DESCRIPTION, RECORD_STATUS, UPDATE_COUNT, CREATOR_ID, CREATE_DATE, UPDATER_ID, UPDATE_DATE)VALUES (6079, 'dms.emailArchive_auto_tracker_incoming_server_password', '', '','S','Password to receive incoming email using auto email archive function','A',0,0,getdate(),0,getdate());
VALUES(9034,'workflow.automatic_task_bindir','D:/ParaDM/file/ParaFlow/AUTOMATICTASK/BIN','D:/ParaDM/file/ParaFlow/AUTOMATICTASK/BIN','S','Automatic Task Compiled Java Classes Directory','A',0,0,getdate(),0,getdate()); 
UPDATE WORKFLOW_ACTION SET CREATE_ID=1 WHERE ID>27;
INSERT INTO SYS_TABLE_KEY VALUES ('WORKING_ACTION', 27);
UPDATE SYS_TABLE_KEY SET TABLE_KEY_MAX = (SELECT MAX(ID) FROM WORKFLOW_ACTION) WHERE TABLE_NAME = 'WORKFLOW_ACTION';

-- By Lun Au (2006-10-24)
-- Requested by Barbin
INSERT INTO SYS_FUNCTION VALUES (6015,'DMS_EMAIL_AUDIT_TRAIL', 'Email Audit Trail', N'電郵審核追蹤', N'电邮审核追踪', '6000', '/dms/ListEmailAuditTrail.do', '16', 'S', 'RIED', 'A', '0', getdate(),0,getdate());
CREATE TABLE DMS_EMAIL_AUDIT_TRAIL (
  ID int NOT NULL,
  USER_ID int NOT NULL,
  OPERATION nvarchar(100) ,
  EMAIL_FROM nvarchar(225),
  EMAIL_TO nvarchar(2000),
  EMAIL_CC nvarchar(2000),
  EMAIL_BCC nvarchar(225),
  EMAIL_SUBJECT nvarchar(225) ,
  EMAIL_TYPE char(1) NOT NULL,
  SENT_DATE datetime,
  ATTCH_NAME nvarchar(2000),
  ATTCH_SOURCE nvarchar(225),
  ATTCH_COUNT int,
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO
CREATE NONCLUSTERED INDEX DEAT_SENT_DATE ON DMS_EMAIL_AUDIT_TRAIL (SENT_DATE)
GO
CREATE NONCLUSTERED INDEX DEAT_EMAIL_SUBJECT ON DMS_EMAIL_AUDIT_TRAIL (EMAIL_SUBJECT)
GO
CREATE NONCLUSTERED INDEX DEAT_USER_ID ON DMS_EMAIL_AUDIT_TRAIL (USER_ID)
GO

-- Requested by Jim Zhou, For EIP-91
ALTER TABLE SYS_USER_DEFINED_INDEX_DETAIL ADD VALUE_SUGGEST char(1)
GO
ALTER TABLE DMS_DEFAULT_PROFILE_SETTING ADD VALUE_SUGGEST_FLAG char(1) NOT NULL
GO
UPDATE DMS_DEFAULT_PROFILE_SETTING SET VALUE_SUGGEST_FLAG='Y';

-- Requested by Lee, Lucene enhancement
CREATE TABLE DMS_DOCUMENT_INDEX_CACHE (
  ID int NOT NULL,
  DMS_DOCUMENT_ID int NOT NULL,
  ACTION_MODE nvarchar(3) NOT NULL,
  ACTION_TYPE nvarchar(7),
  SOURCE_DOCUMENT_ID int,
  RECORD_STATUS char(1) NOT NULL,
  UPDATE_COUNT int NOT NULL,
  CREATOR_ID int NOT NULL,
  CREATE_DATE datetime NOT NULL,
  UPDATER_ID int NOT NULL,
  UPDATE_DATE datetime NOT NULL,
  PRIMARY KEY  (ID)
)
GO

-- Requested by Lee, EIP-568 
UPDATE SYS_FUNCTION SET PERMISSION_TYPE='RIECDS' WHERE ID='6007';

-- Requested by TC, home page channel refresh threshold
INSERT INTO SYS_PARAMETER (ID,PARAMETER_CODE,PARAMETER_VALUE,PARAMETER_DEFAULT_VALUE,PARAMETER_TYPE,DESCRIPTION,RECORD_STATUS,UPDATE_COUNT,CREATOR_ID,CREATE_DATE,UPDATER_ID,UPDATE_DATE) 
VALUES (2017,'display.channel_interval','20000','20000','I','Channel time interval','A',0,0,getdate(),0,getdate());

-- Requested by Great Wall, message management enhancement
ALTER TABLE UPDATE_ALERT_TYPE ADD ALERT_SUBJECT NVARCHAR(255)
GO
INSERT INTO SYS_FUNCTION VALUES (9000,'MSG','Message Management',N'訊息管理',N'讯息管理',0,NULL,4,'S','R','A',0,getdate(),0,getdate());
INSERT INTO SYS_FUNCTION VALUES (9001,'MSG_INBOX','Received Message',N'已收訊息',N'已收讯息',9000,'/ListSystemMessage.do',1,'S','RD','A',0,getdate(),0,getdate());
UPDATE SYS_FUNCTION SET DISPLAY_SEQ=DISPLAY_SEQ+1 WHERE PARENT_ID=0 AND DISPLAY_SEQ > 3;

--
-- THIS STATEMENT SHOULD ALWAYS BE PUT AT THE LAST ROW OF THIS FILE
--
UPDATE SYS_PARAMETER SET PARAMETER_VALUE='$RCSfile: alter3.2.0.sql,v $,$Revision: 1.66 $', UPDATE_COUNT=UPDATE_COUNT+1, UPDATE_DATE=getdate() WHERE ID = -1;
